﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

    public partial class UserInformation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    BindData();
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = "<br>" + ex.Message + "<br><br>";
            }
        }

        private void BindData()
        {
            DataTable dt = new DataTable();
            DBConn oDBConn = new DBConn();
            oDBConn.OpenConnection();

            SqlCommand oCommand = new SqlCommand("sp_Deal_User_SELECTBYID", oDBConn.DBConnection);
            oCommand.CommandType = CommandType.StoredProcedure;
            oCommand.Parameters.Add("@User_ID", SqlDbType.VarChar).Value = Session["USER_USERID"];

            SqlDataAdapter oDataAdapter = new SqlDataAdapter(oCommand);
            oDataAdapter.Fill(dt);
            oDataAdapter = null;
            oDBConn.Disconnect();

            if (dt.Rows.Count > 0)
            {
                lblUserID.Text = dt.Rows[0]["User_ID"].ToString();
                lblName.Text = dt.Rows[0]["User_FirstName"].ToString();
                lblLastname.Text = dt.Rows[0]["User_LastName"].ToString();
                lblEmail.Text = dt.Rows[0]["User_Email"].ToString();
                lblTelNo.Text = dt.Rows[0]["User_TelNo"].ToString();
                lblUserType.Text = dt.Rows[0]["UserType_Name"].ToString();
                if (dt.Rows[0]["User_Status"].ToString() == "True")
                {
                    lblStatus.Text = "Active";
                }
                else
                {
                    lblStatus.Text = "Inactive";
                }
            }
        }
    }
